from .op_basic import *
from ..utils import get_default_manager, get_default_session
import pandas as pd
import os


def read_csv(filename, name=None, *args, **kwargs):
    default_manager = get_default_manager()
    if name is None:
        name = default_manager.get_no_duplicated_name('read_csv_' + os.path.splitext(os.path.basename(filename))[0])

    def read_csv_manager(manager, sess, *args, **kwargs):
        return pd.read_csv(*args, **kwargs)

    args = list(args)
    args.insert(0, filename)
    args = tuple(args)

    return Instance(read_csv_manager, args, kwargs, name=name, manager=default_manager)
